package com.panomedic.kernel;

import com.panomedic.core.Photos;
import com.panomedic.log4j.LogCategories;
import com.panomedic.log4j.Logger;

/**
 *
 * @author Yare
 */
public class Kernel {
    
    Logger logger = new Logger();
    
    /** Unique instance of Kernel. To access Kernel, Kernel.getInstance() must be called */
    private static Kernel instance;
    
    
    private Photos photos = new Photos();
    
    // TODO make debug mode switchable rpom program cmd line
    /** Defines if application is running in debug mode */
    public static boolean DEBUG = true;
    
    private Kernel() {
    }
    
    
    public static void Start() {
        
        instance = new Kernel();
        
        
        Pref.initDefaults();
        
        //showSplash();
        
        instance.startVisualization();
        instance.startControllers();
        instance.startGUI();
        
    }

       
    
    private void startVisualization() {
        VisualHandler.getInstance().startVisualisation();
    }
    private void startControllers() {
        ControllerProxy.getInstance();
    }
    private void startGUI() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Kernel.getInstance();
                VisualHandler.getInstance().setAppFrameVisible(true);
            }
        });
    
    }
    
    public void Terminate() {
        Pref.setCurrent();
        logger.debug(LogCategories.END, "Exiting application...");
        System.exit(0);
    }
    public void Terminate(int code) {
        Pref.setCurrent();
        System.exit(code);
    }

    public static Kernel getInstance() {
        return instance;
    }

    public Photos getPhotos() {
        return photos;
    }
    
}
